
/**用户管理**/
function userManage() {
	document.getElementById("deleteUser").style.display="inline";
	document.getElementById("deleteAdmin").style.display="none";
	document.getElementById("addUser").style.display="inline";
	document.getElementById("addAdmin").style.display="none";
	document.getElementById("initpage").style.display="inline";
	winIframeSrc('mainframe','userManage',1,"");
	
};

/**管理员管理**/
function adminManage() {
	document.getElementById("deleteUser").style.display="none";
	document.getElementById("deleteAdmin").style.display="inline";
	document.getElementById("addUser").style.display="none";
	document.getElementById("addAdmin").style.display="inline";
	document.getElementById("initpage").style.display="none";
	winIframeSrc('mainframe','adminManage',1,"");
	
};

/**资源管理**/
function resourceManage() {
	document.getElementById("deleteUser").style.display="none";
	document.getElementById("deleteAdmin").style.display="none";
	document.getElementById("addUser").style.display="none";
	document.getElementById("addAdmin").style.display="none";
	document.getElementById("initpage").style.display="none";
	winIframeSrc('mainframe','resourceManage',"","");
	
};
/**系统公告管理**/
function noticeManage() {
	document.getElementById("deleteUser").style.display="none";
	document.getElementById("deleteAdmin").style.display="none";
	document.getElementById("addUser").style.display="none";
	document.getElementById("addAdmin").style.display="none";
	document.getElementById("initpage").style.display="none";
	winIframeSrc('mainframe','noticeManage',"","");
	
};

/** 首页**/
function home() {
	window.location.href="/daycodefront/login.jsp";
};

/** 前进**/
function advance() {
	var iframe = document.getElementById('mainframe');
	iframe.contentWindow.history.forward();
};

/**后退**/
function back() {
	var iframe = document.getElementById('mainframe');
	iframe.contentWindow.history.back(-1);
};

/**刷新**/
function refresh() {
	userManage();
};

/**管理员修改个人信息**/
function updateAdmin(id) {
	var src = "adminInfo?&id=" + id; 
	window.frames.msgBox('adminInfoBox', '管理员个人信息',"adminInfoIframe",src);
};

function welcome(levelStr,realNameStr){
	 document.getElementById("level_realName").innerHTML=levelStr+realNameStr;
}

/**退出**/
function exit() {
	if(confirm("确定要退出系统？")){
		window.location.href = "backlogout";
	}else{
		return false;
	}
};

/**跳转至IDE**/
function turnToIDE() {
	window.location.href = "/daycodefront/index.jsp";
};

/**批量删除**/
function deleteMany(str) {
	var iframe = document.getElementById('mainframe');
	if("user"==str){
		iframe.contentWindow.deleteUser("");
	}else if("admin"==str){
		iframe.contentWindow.deleteAdmin();
	}
};

/**新建用户、管理员**/
function add(str) {
	if("user"==str){
		var src = "backstage/jsp/addUserForm.jsp";
		window.frames.msgBox('addUserBox', '新建用户',"addUserIframe",src);
	}else if("admin"==str){
		var src = "backstage/jsp/addAdminForm.jsp";
		window.frames.msgBox('addAdminBox', '新建管理员',"addAdminIframe",src);
	}
};

/**修改个人密码**/
function updateMyPass(id) {
	var src = "updateMyPassForm?&id=" + id;
	window.frames.msgBox('updateMyPassBox', '修改个人密码',"updateMyPassIframe",src);
};


/**------------分页操作------------------**/

/**首页**/
function firstpage() {
	winIframeSrc('mainframe','userManage',1,"");
};

/**上一页**/
function backpage() {
	var current = document.getElementById('current');
	var backUse = document.getElementById('backUse');
	var backUseless = document.getElementById('backUseless');
	var nextUse = document.getElementById('nextUse');
	var nextUseless = document.getElementById('nextUseless');
		if(current.value!=1){
			var pageIndex = parseInt(current.value) - 1;
			winIframeSrc('mainframe','userManage',pageIndex,"");
			nextUse.style.display="inline";
			nextUseless.style.display="none";
			if(current.value==2){
				backUse.style.display="none";
				backUseless.style.display="inline";
			}
		}
};

/**第N页**/
function select() {
	var current = document.getElementById('current');
	var backUse = document.getElementById('backUse');
	var backUseless = document.getElementById('backUseless');
	var nextUse = document.getElementById('nextUse');
	var nextUseless = document.getElementById('nextUseless');
		if(current.value==1){
			backUse.style.display="none";
			backUseless.style.display="inline";
			nextUse.style.display="inline";
			nextUseless.style.display="none";
		}else if(current.value==current.options.length){
			backUse.style.display="inline";
			backUseless.style.display="none";
			nextUse.style.display="none";
			nextUseless.style.display="inline";
		}else{
			backUse.style.display="inline";
			backUseless.style.display="none";
			nextUse.style.display="inline";
			nextUseless.style.display="none";
		}
	winIframeSrc('mainframe','userManage',current.value,"");
};

/**下一页**/
function nextpage() {
	var current = document.getElementById('current');
	var backUse = document.getElementById('backUse');
	var backUseless = document.getElementById('backUseless');
	var nextUse = document.getElementById('nextUse');
	var nextUseless = document.getElementById('nextUseless');
	if(current.value!=current.options.length){
		var pageIndex = parseInt(current.value) + 1;
		winIframeSrc('mainframe','userManage',pageIndex,"");
		backUse.style.display="inline";
		backUseless.style.display="none";
		if(current.value==current.options.length-1){
			nextUse.style.display="none";
			nextUseless.style.display="inline";
		}
	}
};

/**末页**/
function lastpage() {
	var current = document.getElementById('current');
	winIframeSrc('mainframe','userManage',current.options.length,"");
};

/**初始化删除和新建连接显示**/
function initDeleteAdd(){
	document.getElementById("deleteUser").style.display="inline";
	document.getElementById("deleteAdmin").style.display="none";
	document.getElementById("addUser").style.display="inline";
	document.getElementById("addAdmin").style.display="none";
}

/**初始化分页操作**/
function initPage() {
	var current = document.getElementById('current');
	var backUse = document.getElementById('backUse');
	var backUseless = document.getElementById('backUseless');
	var nextUse = document.getElementById('nextUse');
	var nextUseless = document.getElementById('nextUseless');
	if(current.options.length!=1){
		if(current.value==1){
			backUse.style.display="none";
			backUseless.style.display="inline";
			nextUse.style.display="inline";
			nextUseless.style.display="none";
		};
	}else{
		backUse.style.display="none";
		backUseless.style.display="inline";
		nextUse.style.display="none";
		nextUseless.style.display="inline";
		
	}
};


/**搜索操作**/
function searchUser() {
	var findUsername = document.getElementById('findUsername');
	winIframeSrc('mainframe','userManage',"",findUsername.value);
};

/**清空搜索操作**/
function clearSearch() {
	var findUsername = document.getElementById('findUsername');
		findUsername.value="";
		winIframeSrc('mainframe','userManage',"",findUsername.value);
};

/**
 * 监听回车键
 */
document.onkeydown = function(event) {
	event = event ? event : window.event ;
	var findUsername = document.getElementById('findUsername');
	if(document.activeElement.id==("findUsername")){
		if(event.keyCode == 13) { 
			winIframeSrc('mainframe','userManage',"",findUsername.value);
	    } 
	}
};

/**更新iframe src 参数，以刷新**/
function winIframeSrc(iframeId,src,page,findPara){
	var iframe = document.getElementById(iframeId);
	var str = "";
	if("userManage"==src){
		str = src + "?&page=" + page + "&findPara="+ findPara;
		iframe.contentWindow.location.href = str;
	}else if("adminManage"==src){
		str = src + "?&page=" + page + "&findPara="+ findPara;
		iframe.contentWindow.location.href = str;
	}else if("resourceManage"==src){
		iframe.contentWindow.location.href = "file/index.jsp";
	}else if("noticeManage"==src){
		iframe.contentWindow.location.href = "backstage/jsp/noticeManage.jsp";
	}
}

/**获取当前时间**/
function daytime(){
	var d = new Date();
	var week;
	 switch (d.getDay()){
	 case 1: week="星期一"; break;
	 case 2: week="星期二"; break;
	 case 3: week="星期三"; break;
	 case 4: week="星期四"; break;
	 case 5: week="星期五"; break;
	 case 6: week="星期六"; break;
	 default: week="星期日";
	 }
	 var years = d.getYear()+1900;
	 var month = add_zero(d.getMonth()+1);
	 var days = add_zero(d.getDate());
	 var hours = add_zero(d.getHours());
	 var minutes = add_zero(d.getMinutes());
	 var seconds=add_zero(d.getSeconds());
	 var ndate = years+"年"+month+"月"+days+"日 &nbsp;"+hours+":"+minutes+":"+seconds+"&nbsp;&nbsp;"+week;
	 var daytime = document.getElementById("daytime");
	 daytime.innerHTML= ndate;
	 window.setTimeout("daytime()",100);   

}

function add_zero(temp)
{
 if(temp<10) return "0"+temp;
 else return temp;
}
